/**
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
* This file is a part of the CANN Open Software.
* Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/

/*!
* \file matmul_input_l1_cache.h
* \brief
*/
#ifndef IMPL_MATMUL_MODULES_MATMUL_INPUT_L1_CACHE_H
#define IMPL_MATMUL_MODULES_MATMUL_INPUT_L1_CACHE_H

#include "../matmul_module.h"

namespace matmul {

template<typename ENTITY, typename A_TYPE, typename B_TYPE>
class MatmulInputL1Cache
{
public:
    __aicore__ inline void ClearAL1Cache()
    {
        if constexpr (!PhyPosIsL1(A_TYPE::pos)) {
            if (MATMUL_PARAM_VAR.cacheProcA_ > 0) {
                MATMUL_PARAM_VAR.qidA1Cache_.FreeTensor(MATMUL_PARAM_VAR.cacheHeadA1_);
                MATMUL_PARAM_VAR.cacheProcA_ = 0;
            }
        }
    }

    __aicore__ inline void ClearBL1Cache()
    {
        if constexpr (!PhyPosIsL1(B_TYPE::pos)) {
            if (MATMUL_PARAM_VAR.cacheProcB_ > 0) {
                MATMUL_PARAM_VAR.qidB1Cache_.FreeTensor(MATMUL_PARAM_VAR.cacheHeadB1_);
                MATMUL_PARAM_VAR.cacheProcB_ = 0;
            }
        }
    }
};

}
#endif // _MATMUL_INPUT_L1_CACHE_H_